package propcalc_lang;

import java.util.*;

import propcalc_lang.ast.*;

public class Test {

	public static void main(String[] args) {
		Random random = new Random(123456L);
		Map<String, Proposition> replacements1, replacements2;
		Proposition base, substitution;
		
		for (int i = 0; i < 30; i++) {
			base = Proposition.generate(random, 0, 2);
			replacements1 = new HashMap<String, Proposition>();
			for (String id : base.variables(new HashSet<String>())) {
				replacements1.put(id, Proposition.generate(random, 0, 1));
			}
			substitution = base.substitution(replacements1);
			replacements2 = new HashMap<String, Proposition>();
			substitution.match(base, replacements2);
			System.out.println("Pattern: "+ base.unparse());
			System.out.println("Matched: "+ substitution.unparse());
			System.out.print("Replacements:");
			for (Map.Entry<String, Proposition> entry : replacements2.entrySet()) {
				System.out.print(" "+ entry.getKey() +"="+ entry.getValue().unparse());
			}
			System.out.println("\n");
		}
	}

}
